﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Menu.aspx.cs" Inherits="SysManage_Menu" %>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>左边的菜单树</title>
    <link href="SysManage.css" type="text/css" rel="stylesheet" />
    <!--#include file="../JS/MyKeyCode.js"-->
		<script language="javascript" type="text/javascript" >
		 <!--
		 function isChildOf(subCode,code){
	if(subCode<code) return false;
	if(subCode!=code && subCode.substr(0,code.length)==code) return true;
	return false;
}

function isFirstLevelChildOf(subCode,code){
	if(subCode<code) return false;
	if(subCode.length==code.length+3 && subCode.substr(0,code.length)==code) return true;
	return false;
}

/* 伸缩树 */
function flex(obj)
{
	var sSrc = obj.src;
	var index = sSrc.lastIndexOf("/");
	var sImg = sSrc.substr(index + 1);
	var i = sImg.indexOf("_");
	var j = sImg.indexOf(".");
	var status = sImg.substring(i+1,j);
	var sPosition = sImg.substring(0,i);
	var sCode = obj.id.substr(5);
	//当前为舒展，现在要其收缩，收缩所有子孙结点
	if(status=="spread")
	{
		obj.src = "img/sys/"+sPosition+"_retract.gif";
		eval("folder_"+sCode+".src=\"img/sys/folder_close.gif\";");
		for(k=0;k<document.all.length;k++)
		{
			var oElem = document.all[k];
			var sID = oElem.id;
			if(isChildOf(sID,sCode))
				eval(sID+".style.display=\"none\";");
		}
	}
	
	else  //当前为收缩，现在要其舒展，只舒展其下一级子结点	
	{
		obj.src = "img/sys/"+sPosition+"_spread.gif";
		eval("folder_"+sCode+".src=\"img/sys/folder_open.gif\";");
		//先让其下一级目录子结点表现为收缩状态
		for(k=0;k<document.all.length;k++)
		{
			oElem = document.all[k];
			var sID = oElem.id;
			if(isFirstLevelChildOf(sID,sCode))
			{
				if(document.all("flex_"+sID)!=null)
				{
					eval("var sSrc=flex_"+sID+".src;");
					var index = sSrc.lastIndexOf("/");
					var sImg = sSrc.substr(index + 1);
					index = sImg.indexOf("_");
					var sPosition = sImg.substring(0,index);
					eval("flex_"+sID+".src=\"img/sys/"+sPosition+"_retract.gif\";");
					eval("folder_"+sID+".src=\"img/sys/folder_close.gif\";");
				}
			}
		}
		//展开其下一级子结点
		for(k=0;k<document.all.length;k++)
		{
			var oElem = document.all[k];
			var sID = oElem.id;
			if(isFirstLevelChildOf(sID,sCode))
				eval(sID+".style.display=\"\";");
		}
	}
}

//目录展开
function flexTreeByLabel(src)
{
	var sID = src.id;
	var index = sID.lastIndexOf("_");
	var sCode = sID.substring(index+1,sID.length);
	var sIconID = "flex_"+sCode;
	var oIcon = document.getElementById(sIconID);
	flex(oIcon);
}

/* 展开某目录下的第一级子结点 */
function spreadNode(code)
{
	eval("var sSrc = flex_"+code+".src;");
	var index = sSrc.lastIndexOf("/");
	var sImg = sSrc.substr(index + 1);
	index = sImg.indexOf("_");
	var sPosition = sImg.substring(0,index);

	//eval(code+".style.display=\"\";");
	eval("flex_"+code+".src = \"img/sys/"+sPosition+"_spread.gif\";");
	eval("folder_"+code+".src=\"img/sys/folder_open.gif\";");

	for(k=0;k<document.all.length;k++)
	{
      var oElem = document.all[k];
      var sID = oElem.id;
      if(isFirstLevelChildOf(sID,code))
    {
      if(document.all("flex_"+sID)!=null)
      {
        eval("var sSrc=flex_"+sID+".src;");
        var index = sSrc.lastIndexOf("/");
        var sImg = sSrc.substr(index + 1);
        index = sImg.indexOf("_");
        var sPosition = sImg.substring(0,index);
        eval("flex_"+sID+".src=\"img/sys/"+sPosition+"_retract.gif\";");
        eval("folder_"+sID+".src=\"img/sys/folder_close.gif\";");
      }
    }
  }
  for(k=0;k<document.all.length;k++){
    var oElem = document.all[k];
    var sID = oElem.id;
    if(isFirstLevelChildOf(sID,code))
      eval(sID+".style.display=\"\";");
  }
}

/* 舒展树从而使指定的结点呈现 */
function spreadTree(code){
	var nCurLen = 3;
	var nLen = code.length;
	var sSub;
	do{
		sSub = code.substr(0,nCurLen);
		spreadNode(sSub);
		nCurLen = nCurLen + 3;
	}
	while(nCurLen!=nLen);
}

/* 收缩某目录下的第一级子结点 */
function retractTree(code){
	eval("var sSrc = flex_"+code+".src;");
	var index = sSrc.lastIndexOf("/");
	var sImg = sSrc.substr(index + 1);
	index = sImg.indexOf("_");
	var sPosition = sImg.substring(0,index);

	eval("flex_"+code+".src = \"img/sys/"+sPosition+"_retract.gif\";");
	eval("folder_"+code+".src=\"img/sys/folder_close.gif\";");
	for(k=0;k<document.all.length;k++){
		var oElem = document.all[k];
		var sID = oElem.id;
		if(isChildOf(sID,code))
			eval(sID+".style.display=\"none\";");
	}
}

var tgs; 
         var tmp_background_val; 
         function tog(n,flags)
         { 
            //傳過來本次點擊前的的背景顏色 
            if (tgs){ 
             tgs.style.background= tmp_background_val ; 
            } 
            //考慮到連續點同一個對象的情況,就不要改變保留的顏色 
            n.style.background= '#A7C0F9' ; 
            tmp_background_val=flags;
            tgs=n; 
         } 
         
         

  
  document.oncontextmenu = function()
   {
      return false;
   } 
   
		 -->
		 
		 
		</script>
</head>   
<body style ="background-color :#E6EDF7; "   bgcolor="#ffffff"  oncontextmenu="return false" onselectstart="return false" topmargin ="0" leftmargin ="0" rightmargin ="0" bottommargin ="0">
		<table width="181" border="0">
			<tr>
				<td><%=sHtml%></td>
			</tr>			
		</table>
		</body> 
</html>
